package OrderService

import (
	"context"
	toolsDb "gdshop-back-end-go/common/db"
)

func GetOrderAftersaleNumByMemberId(ctx context.Context, memberId int) int {
	count, countErr := toolsDb.GetUnSafaTableAddDeleteWhere(
		ctx,
		"order").As("o").LeftJoin("order_sub os", "o.id = os.order_id").Where(
		"o.delete_at<1 AND o.member_id=? AND os.refund_status IN (?)",
		memberId,
		[]int{
			1,
			2,
			3,
		},
	).Fields(
		"1").Count()
	if countErr != nil {
		return 0
	}

	return count
}
